//
//  BaseIconView.m
//  MarryBackEnd
//
//  Created by KH_MoSi on 2020/7/29.
//  Copyright © 2020 WPP. All rights reserved.
//

#import "BaseIconView.h"

@implementation BaseIconView
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = WhiteColor;
        [self adjustFixedFrame];
    }
    return self;
}
- (void)dealloc
{
    //NSLog(@"BaseIconView ---dealloc");
}
- (void)setIconModel:(BaseIconModel *)iconModel
{
    _iconModel = iconModel;
    
}
- (void)adjustFixedFrame
{
    
}
- (NSMutableAttributedString *)getPlaceholder
{
    NSMutableAttributedString *placeHolder = [[NSMutableAttributedString alloc]initWithString:self.iconModel.placeHolder];
    placeHolder.color = kPlaceholderColor;
    placeHolder.font = [UIFont systemFontOfSize:15*ADAPTER_WIDTH weight:UIFontWeightRegular];
    return placeHolder;
}
- (NSAttributedString *)getPlaceholderTextColor:(UIColor *)color font:(UIFont *)font
{
    NSMutableAttributedString *placeHolder = [[NSMutableAttributedString alloc]initWithString:self.iconModel.placeHolder];
    placeHolder.color = color;
    placeHolder.font = font;
    return placeHolder;
}
#pragma mark - TF
- (void)addObserverPhoneTF:(UITextField *)textField
{
    
}
#pragma mark - lazy懒加载
- (UIView *)lineView
{
    if (!_lineView) {
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = kLineColor;
        view.frame = CGRectMake(16*ADAPTER_WIDTH, self.height - kLineHeight, self.width - 16*ADAPTER_WIDTH, kLineHeight);
        [self addSubview:view];
        _lineView = view;
    }
    return _lineView;
}
- (UIImageView *)arrowIV
{
    if (!_arrowIV) {
        UIImageView *iv = [[UIImageView alloc]init];
        [self addSubview:iv];
        iv.image = [UIImage getPNGimageInBundleWithName:@"Arrow_right_28x28"];
        iv.frame = CGRectMake(self.width - 27*ADAPTER_WIDTH, (self.height - 14*ADAPTER_WIDTH) * 0.5, 14*ADAPTER_WIDTH, 14*ADAPTER_WIDTH);
        _arrowIV = iv;
    }
    return _arrowIV;
}
- (UIImageView *)leftIV
{
    if (!_leftIV) {
        UIImageView *iv = [[UIImageView alloc]init];
        [self addSubview:iv];
        _leftIV = iv;
    }
    return _leftIV;
}
- (UILabel *)leftLab
{
    if (!_leftLab) {
        UILabel *lab = [[UILabel alloc]init];
        [self addSubview:lab];
        lab.textAlignment = NSTextAlignmentLeft;
        lab.numberOfLines = 1;
        lab.font = kFontRegular(15*ADAPTER_WIDTH);
        lab.textColor = kColor51;
        _leftLab = lab;
    }
    return _leftLab;
}
- (UILabel *)rightLab
{
    if (!_rightLab) {
        UILabel *lab = [[UILabel alloc]init];
        [self addSubview:lab];
        lab.textAlignment = NSTextAlignmentRight;
        lab.numberOfLines = 1;
        lab.font = kFontRegular(15*ADAPTER_WIDTH);
        lab.textColor = kColor51;
        _rightLab = lab;
    }
    return _rightLab;
}
- (UITextField *)textField
{
    if (!_textField) {
        UITextField *tf = [[UITextField alloc]init];
        [self addSubview:tf];
        tf.textColor = kColor51;
        tf.font = [UIFont systemFontOfSize:15*ADAPTER_WIDTH weight:UIFontWeightRegular];
        tf.clearButtonMode = UITextFieldViewModeWhileEditing;
        tf.keyboardType = UIKeyboardTypeDefault;//UIKeyboardTypeNumberPad UIKeyboardTypePhonePad电话板面 UIKeyboardTypeDecimalPad 小数点
        tf.tintColor = kGreenColor;
        tf.textAlignment = NSTextAlignmentLeft;
        [tf addTarget:self action:@selector(addObserverPhoneTF:) forControlEvents:UIControlEventEditingChanged];
        tf.secureTextEntry = NO;
        /**
         NSMutableAttributedString *placeHolder = [[NSMutableAttributedString alloc]initWithString:@"请输入充值号码"];
         placeHolder.color = kColor184;
         placeHolder.font = [UIFont systemFontOfSize:15*ADAPTER_WIDTH weight:UIFontWeightRegular];
         tf.attributedPlaceholder = placeHolder;
         */
        _textField = tf;
    }
    return _textField;
}
@end
